/**********************************************************************************
Program:       chinaweathergadget

License:       GNU/GPL version 3

File:          Form_Main.cs

Description:   绘制GUI，包含Main函数

Author:        Guangyu Liu （lgy0417@gmail.com）

Environment:   .NET Framework v2.0 or later version

Usage/Example: README_chs.txt

Last Modified: 2010.08.30

***********************************************************************************/


using System;
using System.Drawing;
using System.Resources;
using System.Windows.Forms;
using System.Collections.Generic;
using WeatherInfo;
using PrettifiedControls.PrettifiedButton;
using PrettifiedControls.PrettifiedComboBox;
using PrettifiedControls.PrettifiedTabControl;


namespace GUI
{
	public delegate void CityListChangedDelegate(List<SingleCity> newCities);
	// 此委托用于在 EditCitiesForm 中回调 GUIMainClass 的 CityListModified 函数
	
	public delegate void AddOrEditOneCityDelegate(SingleCity newCity, bool isAdding);
	// 此委托用于在 AddOrEditOneCityForm 中回调 EditCitiesForm 的 AddOrEditOneCity 函数

	public partial class MainForm : Form
	{
		#region 数据变量
		
		public static readonly string version = "v6.0";
		private ResourceManager rm;
		
		private CurrentCondition cc;
		private WeatherForecast wf;
		private ID_Database idDatabase;
		private CitiesByUser cbu;
		
		private string currentCityName;   // 当前选定的城市，如果更新失败，还原为 previousCityName
		private string previousCityName;  // 用于在更新失败时，恢复到未更新前的状态
		private bool idDatabase_loaded = false;   // 第一次单击编辑按钮后装载数据文件，完毕后此值变为 true
		private bool isStartUp = true;    // 第一次成功取得数据之后将被设置为 false
		
		#endregion
		
		#region TabControl 和 Button
		private TabControlNew tabControl;
		private	ButtonNew refresh;
		private ButtonNew exitButton;
		private ButtonNew editCityListButton;
		#endregion
		
		#region 实时天气
		private static Timer ccTimer = new Timer();
		private TabPage currentConditionPage;
		private Label cityNameLabel;
		private ComboBoxNew cityNameComboBox;
		private Label observationTimeLabel;
		private Label observationTimeValue;
		private Label currentTempLabel;
		private	Label currentTempValue;
		private	Label windDirectionLabel;
		private	Label windDirectionValue;
		private	Label windSpeedLabel;
		private	Label windSpeedValue;
		private	Label humidityLabel;
		private	Label humidityValue;
		private	Label airPressureLabel;
		private	Label airPressureValue;
		#endregion
		
		#region 系统托盘
		private NotifyIcon sysTray;
		private ContextMenuStrip sysTrayMenu;
		private ToolStripMenuItem menuItemOpen;
		private ToolStripMenuItem menuItemUpdate;
		private ToolStripSeparator menuSep;
		private ToolStripMenuItem menuItemAbout;
		private ToolStripMenuItem menuItemExit;
		#endregion
	
		#region 未来 1-3 天预报
		
		private static Timer wfTimer = new Timer();
		private TabPage f3_Page;
		private int indexOfForecast_3_Day1;
		private Label f3_TimeOfPublishing;
		
		private Label f3_Day0_Night;
		
		private Label f3_Day1;
		private Label f3_Day1_DayTime;
		private Label f3_Day1_DayTime_Weather;
		private Label f3_Day1_DayTime_Temp;
		private Label f3_Day1_DayTime_WindDirection;
		private Label f3_Day1_DayTime_WindStrength; 
		private Label f3_Day1_Night;
		private Label f3_Day1_Night_Weather;
		private Label f3_Day1_Night_Temp;
		private Label f3_Day1_Night_WindDirection;
		private Label f3_Day1_Night_WindStrength; 
		
		private Label f3_Day2;
		private Label f3_Day2_DayTime;
		private Label f3_Day2_DayTime_Weather;
		private Label f3_Day2_DayTime_Temp;
		private Label f3_Day2_DayTime_WindDirection;
		private Label f3_Day2_DayTime_WindStrength; 
		private Label f3_Day2_Night;
		private Label f3_Day2_Night_Weather;
		private Label f3_Day2_Night_Temp;
		private Label f3_Day2_Night_WindDirection;
		private Label f3_Day2_Night_WindStrength;
		
		private Label f3_Day3;
		private Label f3_Day3_DayTime;
		private Label f3_Day3_DayTime_Weather;
		private Label f3_Day3_DayTime_Temp;
		private Label f3_Day3_DayTime_WindDirection;
		private Label f3_Day3_DayTime_WindStrength; 
		private Label f3_Day3_Night;
		private Label f3_Day3_Night_Weather;
		private Label f3_Day3_Night_Temp;
		private Label f3_Day3_Night_WindDirection;
		private Label f3_Day3_Night_WindStrength;
		
		#endregion
		
		#region 未来 4-7 天预报
		
		private TabPage f7_Page;
		private int indexOfForecast_7;
		private Label f7_TimeOfPublishing;
		
		private Label f7_Day4;
		private Label f7_Day4_DayTime;
		private Label f7_Day4_DayTime_Weather;
		private Label f7_Day4_DayTime_Temp;
		private Label f7_Day4_DayTime_WindDirection;
		private Label f7_Day4_DayTime_WindStrength; 
		private Label f7_Day4_Night;
		private Label f7_Day4_Night_Weather;
		private Label f7_Day4_Night_Temp;
		private Label f7_Day4_Night_WindDirection;
		private Label f7_Day4_Night_WindStrength; 
		
		private Label f7_Day5;
		private Label f7_Day5_DayTime;
		private Label f7_Day5_DayTime_Weather;
		private Label f7_Day5_DayTime_Temp;
		private Label f7_Day5_DayTime_WindDirection;
		private Label f7_Day5_DayTime_WindStrength; 
		private Label f7_Day5_Night;
		private Label f7_Day5_Night_Weather;
		private Label f7_Day5_Night_Temp;
		private Label f7_Day5_Night_WindDirection;
		private Label f7_Day5_Night_WindStrength; 
		
		private Label f7_Day6;
		private Label f7_Day6_DayTime;
		private Label f7_Day6_DayTime_Weather;
		private Label f7_Day6_DayTime_Temp;
		private Label f7_Day6_DayTime_WindDirection;
		private Label f7_Day6_DayTime_WindStrength; 
		private Label f7_Day6_Night;
		private Label f7_Day6_Night_Weather;
		private Label f7_Day6_Night_Temp;
		private Label f7_Day6_Night_WindDirection;
		private Label f7_Day6_Night_WindStrength; 
		
		private Label f7_Day7;
		private Label f7_Day7_DayTime;
		private Label f7_Day7_DayTime_Weather;
		private Label f7_Day7_DayTime_Temp;
		private Label f7_Day7_DayTime_WindDirection;
		private Label f7_Day7_DayTime_WindStrength; 
		
		#endregion
		
		#region 生活指数
		
		private TabPage shzs_Page;
		private int indexOfShengHuoZhiShu;
		private Label shzs_TimeOfPublishing;
		private Label shzs_UsageTip;
		private ToolTip toolTip1;
		
		private Label shzs_ZiWaiXian;	
		private Label shzs_WuRanKuoSan;	
		private Label shzs_ChuanYi;	
		private Label shzs_ChenLian;
		private Label shzs_ShuShiDu;
		private Label shzs_GanMao;
		private Label shzs_JiaoTong;
		private Label shzs_XiChe;
		private Label shzs_LiangShai;
		private Label shzs_YunDong;
		private Label shzs_LvYou;
		private Label shzs_HuaZhuang;
		private Label shzs_DiaoYu;
		private Label shzs_YueHui;
		private Label shzs_YuSan;
		private Label shzs_LuKuang;
		private Label shzs_HuaChuan;
		private Label shzs_YeShengHuo;
		private Label shzs_GuangJie;	
		private Label shzs_MeiFa;
		
		#endregion

		public MainForm()
		{
			InitializeComponents();
		}
		
		
		[STAThreadAttribute] 
		public static void Main()
		{
			Application.Run(new MainForm());
		}
		
	}
}
